package com.etc.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.service.impl.AnnouncementServiceImpl;
import com.etc.entity.Announcement;

import com.etc.service1.AnnouncementService;
import com.etc.util.PageTool;

/**
 * Servlet implementation class ListAnnouncementServlet
 */
@WebServlet("/ListAnnouncementServlet")
public class ListAnnouncementServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListAnnouncementServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		  AnnouncementService an=new AnnouncementServiceImpl();
		  List<Announcement> list=an.listAnnouncement();
		  String sf=request.getParameter("sf");
	      request.setAttribute("AnnouncementList", list);
            if(sf.equals("user")){
            	request.getRequestDispatcher("gglistuser.jsp").forward(request, response);
			/*
			 * request.getRequestDispatcher("html/welcome_user.jsp").forward(request,
			 * response);
			 */
            }
            else {
		  request.getRequestDispatcher("gglist.jsp").forward(request, response);
			/*
			 * request.getRequestDispatcher("html/welcome_admin.jsp").forward(request,
			 * response);
			 */
            }
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
